package com.qf.controller;

import com.qf.pojo.UserInfo;
import com.qf.pojo.UserRole;
import com.qf.service.UserInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserInfoController {
    @Resource
    UserInfoService userInfoService;
    @RequestMapping("/findAllUserInfo")
    public List<UserInfo> findAllUserInfo(){
        System.out.println(userInfoService.findAll());
        return userInfoService.findAll();
    }
    @RequestMapping("/findByUuid/{uuid}")
    public UserInfo findByUrid(@PathVariable("uuid")Integer uuid){
        return userInfoService.findByuuid(uuid);
    }

    @RequestMapping(value = "/addUserInfo",method = RequestMethod.POST)
    public int addUserInfo(@RequestBody UserInfo userInfo){
        int add = userInfoService.add(userInfo);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateUserInfo",method = RequestMethod.POST)
    public int updateUserInfo(@RequestBody UserInfo userInfo){
        int update = userInfoService.update(userInfo);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteUserInfo/{uuid}")
    public int deleteUserInfo(@PathVariable("uuid")int uuid) {
        int delete = userInfoService.delete(uuid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }
}
